package com.restaurant.serviceimpl;

import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import com.restaurant.domain.Modifireinventory;
import com.restaurant.service.ModifireinventoryService;

public class ModifireinventoryServiceImpl implements ModifireinventoryService {

   private HibernateTemplate hibernateTemplate;

   @Autowired
   public void setSessionFactory(SessionFactory sessionFactory){
       this.hibernateTemplate = new HibernateTemplate(sessionFactory);
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Modifireinventory addOrModify( Modifireinventory objModifireinventory ) {
       return ( Modifireinventory ) hibernateTemplate.merge( objModifireinventory );
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Modifireinventory deleteRecord( Modifireinventory objModifireinventory ) {
       hibernateTemplate.delete( objModifireinventory );
       return objModifireinventory;
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Modifireinventory modifyRecord( Modifireinventory objModifireinventory ) {
       return ( Modifireinventory ) hibernateTemplate.merge( objModifireinventory );
   }

   @SuppressWarnings("unchecked")
   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public List<Modifireinventory> loadAll() {
       return (List<Modifireinventory>)hibernateTemplate.findByNamedQuery( "Modifireinventory.findAll");
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Modifireinventory loadByPrimaryKey( Long primaryKey ) {
       return (Modifireinventory) hibernateTemplate.get( Modifireinventory.class, primaryKey );
   }

   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public Modifireinventory deleteByPrimaryKey( Long primaryKey ) {
       return deleteRecord(loadByPrimaryKey(primaryKey));
   }

   @SuppressWarnings("unchecked")
   @Override
   @Transactional(propagation = Propagation.REQUIRED, isolation=Isolation.DEFAULT)
   public List<Modifireinventory> loadByHql(String query) {
       return ( List<Modifireinventory> ) hibernateTemplate.find( query );
   }
}